package com.atguigu.command;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:  电灯打开的命令
 * @create: 2022-03-01 14:00
 **/
public class LightOnCommand implements Command{

    /**
     * 聚合(电灯接收者)
     */
    private final LightReceiver lightReceiver;

    public LightOnCommand(LightReceiver lightReceiver) {
        this.lightReceiver = lightReceiver;
    }

    @Override
    public void execute() {
        //调用接收者的方法(可以是接收者的任一方法：打开或关闭)
        lightReceiver.on();
    }

    @Override
    public void undo() {
        //调用接收者的方法(可以是接收者的任一方法：打开或关闭)
        lightReceiver.off();
    }
}
